package com.thrd.basicframework.utils;

import android.content.Context;

import com.danikula.videocache.HttpProxyCacheServer;

/**
 * @author: ${唐杰}
 * @date: 2021/4/11
 */
public class ProxyCache {
    private static ProxyCache instance = new ProxyCache();
    private ProxyCache (){}
    private Context context;
    public static ProxyCache getInstance() {
        return instance;
    }

    public void  init(Context context){
        this.context=context;
    }

    private HttpProxyCacheServer proxy;

    public  HttpProxyCacheServer getProxy() {
        return proxy == null ? (proxy = newProxy()) : proxy;

    }

    private HttpProxyCacheServer newProxy() {
        return new HttpProxyCacheServer.Builder(context)
                .maxCacheSize(1024 * 1024 * 1024*5)       // 1 Gb for cache
                .maxCacheFilesCount(100)
               // .fileNameGenerator(new MyFileNameGenerator())
                .build();


    }

}
